﻿using System.Data;
using System.Data.SqlClient;
namespace MyWeb.Data
{
	public class tblSTUDENTDAL : SqlDataProvider
	{

		#region[tblSTUDENT_GetbyAll]
		public DataTable tblSTUDENT_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTUDENT_GetbyId]
		public DataTable tblSTUDENT_GetById(string STUDENT_ID)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STUDENT_ID", STUDENT_ID));return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTUDENT_GetbyTop]
		public DataTable tblSTUDENT_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				return GetTable(cmd);
			}
		}
		#endregion
		#region[tblSTUDENT_GetbyCLASS_ID]
		public DataTable tblSTUDENT_GetByCLASS_ID(string CLASS_ID)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_GetByCLASS_ID", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@CLASS_ID", CLASS_ID));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblSTUDENT_Insert]
		public void tblSTUDENT_Insert(tblSTUDENTInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@CLASS_ID", Data.CLASS_ID));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_CODE", Data.STUDENT_CODE));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_FIRSTNAME", Data.STUDENT_FIRSTNAME));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_LASTNAME", Data.STUDENT_LASTNAME));
				cmd.Parameters.Add(new SqlParameter("@ADDRESS", Data.ADDRESS));
				cmd.Parameters.Add(new SqlParameter("@BIRTHDAY", Data.BIRTHDAY));
				cmd.Parameters.Add(new SqlParameter("@EMAIL", Data.EMAIL));
				cmd.Parameters.Add(new SqlParameter("@STATUS", Data.STATUS));
				cmd.Parameters.Add(new SqlParameter("@CREATOR", Data.CREATOR));
				cmd.Parameters.Add(new SqlParameter("@CREATED_DATE", Data.CREATED_DATE));
				cmd.Parameters.Add(new SqlParameter("@MODIFIER", Data.MODIFIER));
				cmd.Parameters.Add(new SqlParameter("@MODIFIED_DATE", Data.MODIFIED_DATE));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion
		#region[tblSTUDENT_Update]
		public void tblSTUDENT_Update(tblSTUDENTInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STUDENT_ID", Data.STUDENT_ID));
				cmd.Parameters.Add(new SqlParameter("@CLASS_ID", Data.CLASS_ID));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_CODE", Data.STUDENT_CODE));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_FIRSTNAME", Data.STUDENT_FIRSTNAME));
				cmd.Parameters.Add(new SqlParameter("@STUDENT_LASTNAME", Data.STUDENT_LASTNAME));
				cmd.Parameters.Add(new SqlParameter("@ADDRESS", Data.ADDRESS));
				cmd.Parameters.Add(new SqlParameter("@BIRTHDAY", Data.BIRTHDAY));
				cmd.Parameters.Add(new SqlParameter("@EMAIL", Data.EMAIL));
				cmd.Parameters.Add(new SqlParameter("@STATUS", Data.STATUS));
				cmd.Parameters.Add(new SqlParameter("@CREATOR", Data.CREATOR));
				cmd.Parameters.Add(new SqlParameter("@CREATED_DATE", Data.CREATED_DATE));
				cmd.Parameters.Add(new SqlParameter("@MODIFIER", Data.MODIFIER));
				cmd.Parameters.Add(new SqlParameter("@MODIFIED_DATE", Data.MODIFIED_DATE));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion
		#region[tblSTUDENT_Delete]
		public void tblSTUDENT_Delete(string STUDENT_ID)
		{
			using (var cmd = new SqlCommand("sp_tblSTUDENT_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@STUDENT_ID",STUDENT_ID));
				ExeCuteNonquery(cmd);
			}
		}
		#endregion
	}
}